package com.xhh.nphm.system.mapper;

import com.xhh.nphm.system.domain.LoginState;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

/**
 * @Program: hw-zhuanban
 * @ClassName SysUserLoginSateDao
 * @Author: liutao
 * @Description: 用户登录情况
 * @Create: 2022-07-27 15:17
 * @Version 1.0
 **/
@Mapper
public interface SysUserLoginSateDao {
    @Select("{call loginState(#{deptParentId,mode=IN,jdbcType=BIGINT})}")
//    @Results(id = "loginResult",value = {
//            @Result(property = "tid",column = "tid"),
//            @Result(property = "deptName",column = "deptName"),
//            @Result(property = "onlineCount",column = "onlineCount"),
//            @Result(property = "allCount",column = "allCount"),
//            @Result(property = "orderCount",column = "orderCount"),
//            @Result(property = "recentTime",column = "recentTime"),
//    })
    @Options(statementType = StatementType.CALLABLE)
    List<Map> loginState(@Param("deptParentId") String deptParentId);
    @Select("SELECT count(1) FROM tm_sys_user a JOIN [bUserDept] b ON a.dept_id= b.NoSelf AND b.NoParent= #{deptParentId}")
    int areaAllCount(Long deptParentId);
    @Select("SELECT COUNT(1) FROM tm_sys_user_online a JOIN tm_sys_user b ON a.login_name= b.login_name JOIN bUserDept c ON b.dept_id= c.NoSelf AND c.NoParent = #{deptParentId} ")
    int areaOnlineCount(Long deptParentId);
}
